A periodic task that generates timed pulses on a GPIO output pin.
More...
#include <PulsedGPIOPin.h>
A periodic task that generates timed pulses on a GPIO output pin.
◆ PULSE_TYPE
This enumeration defines whether the pin pulses once (ONE_SHOT) each time a pulse duration is set, or every period (CONTINUOUS).
◆ PulsedGPIOPin()
| PulsedGPIOPin::PulsedGPIOPin |
( |
int |
number, |
|
|
std::string |
threadName, |
|
|
uint32_t |
period, |
|
|
PULSE_TYPE |
type = CONTINUOUS, |
|
|
GPIO::DIRECTION |
dir = GPIO::GPIO_OUT, |
|
|
GPIO::VALUE |
val = GPIO::GPIO_LOW |
|
) |
| |
This will setup a GPIO pin to be pulsed.
- Parameters
-
| number | This is the GPIO pin that is to be pulsed. |
| threadName | This is the name of the thread for the pin. |
| period | This is the period of the task that is to cause a pulse, in microseconds. |
| type | This is the type of the pulse, either One Shot, which fires once, or Continuous, which will have a given pulse every period units of time. |
| dir | This is the direction for the pin - out for it to be meaningful. |
| val | This is the default pin state value, which tends to be low. |
This will setup a GPIO pin to be pulsed.
- Parameters
-
| number | This is the GPIO pin that is to be pulsed. |
| threadName | This is the name of the thread for the pin. |
| period | This is the period of the task that is to cause a pulse, in microseconds. |
| type | This is the type of the pulse, either ONE_SHOT or CONTINUOUS. |
| dir | This is the direction for the pin - out for it to be meaningful. |
| val | This is the default pin state value, which tends to be low. |
◆ ~PulsedGPIOPin()
| PulsedGPIOPin::~PulsedGPIOPin |
( |
| ) |
|
|
virtual |
This is the destructor. It does not release the GPIO instance.
◆ delayedToggleAndSleep()
This method raises the calling thread to priority 55, sleeps for the given delay, writes the given value to the pin, and then restores the task priority. It is not currently called.
- Parameters
-
| specificDelay | This is the delay, in microseconds. |
| value | This is the value to write to the pin after the delay. |
◆ setpulseDuration()
| void PulsedGPIOPin::setpulseDuration |
( |
int |
duration | ) |
|
|
virtual |
This method will set the pulse duration, or how long the pulse should be on. It also arms the pulse so that a ONE_SHOT pin fires on its next period.
- Parameters
-
| duration | This is the time on, in microseconds. It must be less than one second. |
This method will set the pulse duration, or how long the pulse should be on, and arm the pulse.
- Parameters
-
| duration | This is the time on, in microseconds. It must be less than one second. |
◆ setValue()
This method is intended to drive the output pin to the given value. It is currently empty and has no effect; the pin is driven only by taskMethod().
- Parameters
-
| value | This is the value that is to be written to the pin. |
This method is intended to drive the output pin to the given value. It is currently empty and has no effect.
- Parameters
-
| value | This is the value that is to be written to the pin. |
◆ stopThreadExecution()
| void PulsedGPIOPin::stopThreadExecution |
( |
| ) |
|
|
virtual |
This method will stop the thread and its execution. In the case of this particular class, it will also return the pin to its initial value and detach the thread, so waitForShutdown() will not wait for it.
This method will stop the thread and its execution. It returns the pin to its initial value, requests the periodic task to stop, and detaches the thread so that it is not joined later.
Reimplemented from SWE4211RPi::RunnableClass.
◆ taskMethod()
| void PulsedGPIOPin::taskMethod |
( |
| ) |
|
|
virtual |
This is the overridden taskMethod that is periodically invoked. If a pulse is due, it drives the pin to the opposite of the initial value, sleeps for the pulse duration, and returns the pin to the initial value.
This is the periodic task method. If a pulse is due (the pin is CONTINUOUS, or a ONE_SHOT pin has been armed), it drives the pin to the opposite of the initial value, sleeps for the pulse duration, and returns the pin to the initial value.
Implements SWE4211RPi::PeriodicTask.
◆ firePulse
| bool SWE4211RPi::PulsedGPIOPin::firePulse = false |
|
private |
This flag is set when a new pulse duration is set. A ONE_SHOT pin pulses only while it is set.
◆ gpioPinInstance
| GPIO& SWE4211RPi::PulsedGPIOPin::gpioPinInstance |
|
private |
This is the GPIO pin that is being pulsed.
◆ initialValue
The initial value for the GPIO pin.
◆ pulseDuration
| int SWE4211RPi::PulsedGPIOPin::pulseDuration = 0 |
|
private |
The duration of each pulse, in microseconds.
◆ type
This defines the type of the pulse.
The documentation for this class was generated from the following files:
- /media/sf_lwshare/20262027SWE4211AllLabSolutions/Lab11/solution/pi/src/gpio/provided/PulsedGPIOPin.h
- /media/sf_lwshare/20262027SWE4211AllLabSolutions/Lab11/solution/pi/src/gpio/provided/PulsedGPIOPin.cpp