PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
PropWare::DualPWM Class Reference

Dual-pin PWM driver. Requires a cog to run and will use both counter modules in that cog. More...

#include <PropWare/gpio/dualpwm.h>

+ Inheritance diagram for PropWare::DualPWM:
+ Collaboration diagram for PropWare::DualPWM:

Public Member Functions

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.
 

Static Public Member Functions

template<class T >
static int8_t invoke (T &runnable)
 Start a new cog running the given object. More...
 

Static Public Attributes

static const unsigned int MAX_DUTY = 4096
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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]frequencyFrequency of the wave, in Hertz
[in]mask1Pin mask of the first pin
[in]mask2Pin mask of the second pin
[in]*duty1Address of the duty cycle variable for the first pin
[in]*duty2Address of the duty cycle variable for the second pin
[in]*stackAddress of the stack. Should have allocated 48 32-bit words.
[in]stackLengthNumber of 32-bit words in the stack

Definition at line 83 of file dualpwm.h.

Member Function Documentation

◆ invoke()

template<class T >
static int8_t PropWare::Runnable::invoke ( T &  runnable)
staticinherited

Start a new cog running the given object.

Parameters
[in]runnableObject 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.

+ Here is the call graph for this function:

Member Data Documentation

◆ 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: