|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Go to the documentation of this file.
63 volatile unsigned int *duty1,
volatile unsigned int *duty2,
const uint32_t (&stack)[N])
84 volatile unsigned int *duty1,
volatile unsigned int *duty2,
const uint32_t *stack,
85 const size_t stackLength)
98 DIRA |= this->m_mask1;
104 DIRA |= this->m_mask2;
107 const register unsigned int period = this->m_period;
109 auto timer =
CNT + period;
111 const auto leftPhase = *this->m_duty1 * period /
MAX_DUTY;
112 const auto rightPhase = *this->m_duty2 * period /
MAX_DUTY;
113 __asm__
volatile(
"neg PHSA, %0" : :
"r" (leftPhase));
114 __asm__
volatile(
"neg PHSB, %0" : :
"r" (rightPhase));
120 const unsigned int m_period;
123 volatile unsigned int *m_duty1;
124 volatile unsigned int *m_duty2;
static uint8_t from_mask(const Mask mask)
Determine which pin number based on a pin mask.
static const unsigned int MAX_DUTY
Dual-pin PWM driver. Requires a cog to run and will use both counter modules in that cog.
#define FRQA
Counter A frequency register.
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.
#define waitcnt2(a, b)
Wait until system counter reaches a value.
#define FRQB
Counter B frequency register.
Helper class for creating easy parallel applications.
#define CLKFREQ
Returns the current clock frequency.
#define CTRB
Counter B control register.
void run()
Invoked in the new cog, this method should be the root of the business logic.
#define CNT
The system clock count.
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.
#define DIRA
Use to set pins to input (0) or output (1).
Generic definitions and functions for the Parallax Propeller.
#define CTRA
Counter A control register.