Dual-pin PWM driver. Requires a cog to run and will use both counter modules in that cog.
More...
#include <PropWare/gpio/dualpwm.h>
|
template<size_t N> |
| DualPWM (const unsigned int frequency, const Pin::Mask mask1, const Pin::Mask mask2, volatile unsigned int *duty1, volatile unsigned int *duty2, const uint32_t(&stack)[N]) |
| Construct a DualPWM instance. More...
|
|
| DualPWM (const unsigned int frequency, const Pin::Mask mask1, const Pin::Mask mask2, volatile unsigned int *duty1, volatile unsigned int *duty2, const uint32_t *stack, const size_t stackLength) |
| Construct a DualPWM instance. More...
|
|
void | run () |
| Invoked in the new cog, this method should be the root of the business logic.
|
|
|
template<class T > |
static int8_t | invoke (T &runnable) |
| Start a new cog running the given object. More...
|
|
|
static const unsigned int | MAX_DUTY = 4096 |
|
Dual-pin PWM driver. Requires a cog to run and will use both counter modules in that cog.
The duty cycle should be a value between 0 and 4096, inclusive. The code has been successfully tested up to 80 kHz with the CMM memory model. The maximum frequency should not vary significantly with memory model as the core loop is typically cached via fcache.
- Examples
- DualPWM_Demo.cpp.
Definition at line 40 of file dualpwm.h.
◆ DualPWM() [1/2]
template<size_t N>
PropWare::DualPWM::DualPWM |
( |
const unsigned int |
frequency, |
|
|
const Pin::Mask |
mask1, |
|
|
const Pin::Mask |
mask2, |
|
|
volatile unsigned int * |
duty1, |
|
|
volatile unsigned int * |
duty2, |
|
|
const uint32_t(&) |
stack[N] |
|
) |
| |
Construct a DualPWM instance.
- Template Parameters
-
Definition at line 62 of file dualpwm.h.
◆ DualPWM() [2/2]
PropWare::DualPWM::DualPWM |
( |
const unsigned int |
frequency, |
|
|
const Pin::Mask |
mask1, |
|
|
const Pin::Mask |
mask2, |
|
|
volatile unsigned int * |
duty1, |
|
|
volatile unsigned int * |
duty2, |
|
|
const uint32_t * |
stack, |
|
|
const size_t |
stackLength |
|
) |
| |
Construct a DualPWM instance.
- Parameters
-
[in] | frequency | Frequency of the wave, in Hertz |
[in] | mask1 | Pin mask of the first pin |
[in] | mask2 | Pin mask of the second pin |
[in] | *duty1 | Address of the duty cycle variable for the first pin |
[in] | *duty2 | Address of the duty cycle variable for the second pin |
[in] | *stack | Address of the stack. Should have allocated 48 32-bit words. |
[in] | stackLength | Number of 32-bit words in the stack |
Definition at line 83 of file dualpwm.h.
◆ invoke()
template<class T >
static int8_t PropWare::Runnable::invoke |
( |
T & |
runnable | ) |
|
|
staticinherited |
Start a new cog running the given object.
- Parameters
-
[in] | runnable | Object that should be invoked in a new cog |
- Returns
- If the cog was successfully started, the new cog ID is returned. Otherwise, -1 is returned
Definition at line 85 of file runnable.h.
◆ MAX_DUTY
const unsigned int PropWare::DualPWM::MAX_DUTY = 4096 |
|
static |
Maximum value for the duty cycle. Setting the duty cycle to this value will result in a permanently high logic value on the associated GPIO pin. Valid values for the duty cycle are between zero and this value.
Definition at line 46 of file dualpwm.h.
The documentation for this class was generated from the following file: