63 m_pwm.
set(pwm, m_inverted);
75 SEMF_INFO(
"reduced pwm %u to max 1000", pwm);
78 setValue(
static_cast<uint32_t
>(
static_cast<uint64_t
>(m_pwm.
maxValue()) * pwm / 1000));
83 return static_cast<uint16_t
>(m_pwm.
value() * 1000ULL / m_pwm.
maxValue());
91 SEMF_INFO(
"set max value to 1 instead of 0");
108 SEMF_INFO(
"set inverted to %d", inverted);
109 m_inverted = inverted;
Class to interface pwm's hardware module of the microcontroller.
virtual unsigned int value() const =0
Returns the current PWM value.
virtual void set(unsigned int value, bool inverted=false)=0
Set a PWM value. Duty cycle is value / maxValue.
virtual bool isEnabled() const =0
Returns the current status of PWM module.
virtual void setMaxValue(unsigned int maxValue)=0
Set the maximum possible PWM value.
virtual unsigned int maxValue() const =0
Returns the maximum possible PWM value.
void enable(bool enable=true) override
Enables / disable the PWM output.
bool isEnabled() const override
Current status of the PWM module.
uint32_t value() const override
Returns the current PWM value.
void stop() override
Disable the PWM.
uint16_t permille() const override
Returns the current PWM value in permille. The PWM value is calculated based on the set maximum value...
void disable(bool disable=true) override
Enables / disable the PWM output.
void start() override
Enables the PWM.
void setPermille(uint16_t pwm) override
Set the PWM value in permille. The pwm value is calculated based on the set maximum value.
void setMaxValue(uint32_t pwm) override
Set the maximum value for the PWM.
PwmOut(Pwm &pwm)
Constructor.
uint32_t maxValue() const override
Returns the maximum possible PWM value.
void setInverted(bool inverted) override
To configure whether the PWM should be inverted. This configuration does not become active until the ...
void setValue(uint32_t pwm) override
Change the PWM value.