microbit-dal: DynamicPWM now has a static period member variable

Previously DynamicPWM had a per instance member variable that was not shared across all instances of DyanmicPWM which is not true to the hardware, that shares a period across all pwm channels.

This commit adds a static member variable, and sets the default to 20000 us - a default set at the mbed layer.
This commit is contained in:
James Devine 2017-02-24 10:22:51 +00:00
parent 15194f2ed2
commit b90c21de1c
2 changed files with 4 additions and 3 deletions

View file

@ -40,7 +40,7 @@ DEALINGS IN THE SOFTWARE.
class DynamicPwm : public PwmOut
{
private:
uint32_t period;
static uint32_t period;
float lastValue;
public:

View file

@ -35,6 +35,8 @@ DEALINGS IN THE SOFTWARE.
#include "MicroBitPin.h"
#include "ErrorNo.h"
uint32_t DynamicPwm::period = MICROBIT_DEFAULT_PWM_PERIOD;
/**
* An internal constructor used when allocating a new DynamicPwm instance.
*
@ -45,7 +47,6 @@ DEALINGS IN THE SOFTWARE.
*/
DynamicPwm::DynamicPwm(PinName pin) : PwmOut(pin)
{
this->period = 0;
}
/**
@ -131,7 +132,7 @@ int DynamicPwm::getValue()
*/
uint32_t DynamicPwm::getPeriodUs()
{
return period;
return this->period;
}
/**