GPIO GPIO wrapper classes for usage with C++ and wiringPi.
More...
#include <GPIO.h>
|
| enum | DIRECTION { GPIO_IN
, GPIO_OUT
} |
| |
| enum | VALUE { GPIO_LOW = 0
, GPIO_HIGH = 1
} |
| |
| enum | EDGE { GPIO_NONE
, GPIO_RISING
, GPIO_FALLING
, GPIO_BOTH
} |
| |
GPIO GPIO wrapper classes for usage with C++ and wiringPi.
◆ DIRECTION
This enumeration sets up the pin to either be an input or an output pin.
◆ EDGE
This enumeration is used to define whether an ISR is fired based on transitions in pin values.
◆ VALUE
This enumeration defines the values on the pin as being either high or low.
◆ callBackThreadHandler()
| void SWE4211RPi::GPIO::callBackThreadHandler |
( |
| ) |
|
|
virtual |
This method is used by the friend method to handle callback methods. It should never be invoked from outside of the class. In essence, what it will do a loop so long as the callback method is not NULL, invoking the callback method whenever an edge transitions.
◆ disableEdgeInterrupt()
| virtual void SWE4211RPi::GPIO::disableEdgeInterrupt |
( |
| ) |
|
|
pure virtual |
◆ enableEdgeInterrupt()
| virtual void SWE4211RPi::GPIO::enableEdgeInterrupt |
( |
EDGE |
edgeType | ) |
|
|
pure virtual |
This method will enable an interrupt to be processed based upon edges. In doing this, callbacks can be made based upon the GPIO pin changing state and methods can block for IO purposes.
- Parameters
-
| edgeType | This is the edge type that is to be processed as an interrupt. |
Implemented in SWE4211RPi::WiringPiGPIO.
◆ getFallingISRTimestamp()
| struct timespec SWE4211RPi::GPIO::getFallingISRTimestamp |
( |
| ) |
|
|
virtual |
This method will obtain the timestamp from the last time the pin transitioned low.
- Returns
- The timestamp of the transition will be returned.
◆ getPinNumber()
| int SWE4211RPi::GPIO::getPinNumber |
( |
| ) |
|
|
virtual |
This method will obtain the GPIO Pin number associated with this instance of the GPIO class.
- Returns
- The unique pin number identifying the pin will be returned.
◆ getRisingISRTimestamp()
| struct timespec SWE4211RPi::GPIO::getRisingISRTimestamp |
( |
| ) |
|
|
virtual |
This method will obtain the timestamp from the last time the pin transitioned high.
- Returns
- The timestamp of the transition will be returned.
◆ getValue()
This method will return the current state of this GPIO pin.
- Returns
- The return will be high or low depending on the state of the pin.
Implemented in SWE4211RPi::WiringPiGPIO.
◆ handleInterruptDrivenGPIOPin()
| virtual void SWE4211RPi::GPIO::handleInterruptDrivenGPIOPin |
( |
| ) |
|
|
pure virtual |
This method will be invoked if an interrupt is enabled whenever a transition in pin value occurs.
Implemented in SWE4211RPi::WiringPiGPIO.
◆ setCallbackMethod()
| void SWE4211RPi::GPIO::setCallbackMethod |
( |
CallbackType |
methodCallback | ) |
|
|
virtual |
This method will set the callback handler. If this is NULL, no method will be invoked. However, if it is non-NULL and the class triggers on edges, the method described here will be called when an edge transition occurs.
- Parameters
-
| methodCallback | This is a function pointer that is to be used on the callback. |
◆ setValue()
| virtual void SWE4211RPi::GPIO::setValue |
( |
GPIO::VALUE |
| ) |
|
|
pure virtual |
This method will drive an output pin to the appropriate value.
- Parameters
-
| This | is the value that is to be written to the pin. |
Implemented in SWE4211RPi::WiringPiGPIO.
◆ waitForEdge()
| int SWE4211RPi::GPIO::waitForEdge |
( |
int |
maxWait | ) |
|
|
virtual |
This method will block the calling thread for up to maxWait ms unless an edge occurs. Note that this should only be called once at a time, as multiple invocations will result in non-deterministic behavior.
- Parameters
-
| maxWait | This is the maximum blocked period in ms. |
- Returns
- 0 if the edge occurred or -1 if a timeout occurred.
This method will block the calling thread for up to maxWait ms unless an edge occurs.
- Parameters
-
| maxWait | This is the maximum blocked period in ms. |
- Returns
- 0 if the edge occurred or -1 if a timeout occurred.
◆ cv
| std::condition_variable SWE4211RPi::GPIO::cv |
|
protected |
These two condition variables are used internally to allow the invocation of a callback method and a block for edge method.
◆ gpio_instances
| GPIO * SWE4211RPi::GPIO::gpio_instances |
|
static |
This static variable keeps track of the GPIO instances as they are instantiated. It is used to ensure that we can reference a given instance based upon the GPIO number of the given pin.
◆ instanceCount
| int SWE4211RPi::GPIO::instanceCount = 0 |
|
protected |
This is the number of references to the GPIO pin that have been returned.
◆ isrFallingTimestamp
| struct timespec SWE4211RPi::GPIO::isrFallingTimestamp |
|
protected |
This is a timestamp marked when a falling edge is detected within the system, if the system is setup to handle edges.
◆ isrRisingTimestamp
| struct timespec SWE4211RPi::GPIO::isrRisingTimestamp |
|
protected |
This is a timestamp marked when a rising edge is detected within the system, if the system is setup to handle edges.
◆ methodCallback
| CallbackType SWE4211RPi::GPIO::methodCallback =nullptr |
|
protected |
This is a callback variable that is used to invoke a method when a transition in the GPIO value occurs.
◆ mtx
| std::mutex SWE4211RPi::GPIO::mtx |
|
protected |
This is a mutex that is used to protect critical resources within this class.
◆ number
| int SWE4211RPi::GPIO::number =0 |
|
protected |
This is the GPIO pin number for the given pin.
The documentation for this class was generated from the following files:
- /media/sf_lwshare/20262027SWE4211AllLabSolutions/Lab5/samplesolution/PiCode/src/gpio/provided/GPIO.h
- /media/sf_lwshare/20262027SWE4211AllLabSolutions/Lab5/samplesolution/PiCode/src/gpio/provided/GPIO.cpp