30PWM::PWM(TIM_TypeDef*
const pulseTimer, uint16_t pulseFrequency)
31 : pulseTimer(pulseTimer), pulseFrequency(pulseFrequency)
34 this->pulseTimer.reset();
39 this->pulseTimer.enable();
46 this->pulseFrequency = pulseFrequency;
52 this->dutyCycleResolution = dutyCycleResolution;
80 if (dutyCycle >= 0 && dutyCycle <= 1)
84 static_cast<uint16_t
>(
97void PWM::configureTimer()
99 pulseTimer.
setFrequency(dutyCycleResolution * pulseFrequency);
virtual void generateUpdate() final
Re-initializes the timer counter and generate an update of the registers (the prescaler is cleared to...
virtual void setFrequency(int frequency) final
Allows to set directly the frequency of the timer's clock.
void enableCaptureCompareOutput(TimerUtils::Channel channel)
void setCaptureCompareRegister(TimerUtils::Channel channel, T value)
void enableCaptureComparePreload(TimerUtils::Channel channel)
The capture/compare register is buffered.
void setOutputCompareMode(TimerUtils::Channel channel, TimerUtils::OutputCompareMode modeChannel)
void setCaptureComparePolarity(TimerUtils::Channel channel, TimerUtils::OutputComparePolarity polarity)
void reset() override
Resets the timer configuration to the default state.
void setAutoReloadRegister(T autoReloadValue)
T readCaptureCompareRegister(TimerUtils::Channel channel)
void disableCaptureCompareOutput(TimerUtils::Channel channel)
bool isCaptureCompareOutputEnabled(TimerUtils::Channel channel)
T readAutoReloadRegister()
void disableChannel(TimerUtils::Channel channel)
void setDutyCycle(TimerUtils::Channel channel, float dutyCycle)
Sets the duty cycle for the specified channel.
bool isChannelEnabled(TimerUtils::Channel channel)
float getDutyCycle(TimerUtils::Channel channel)
Return the channel's duty cycle in the range [0,1].
void setDutyCycleResolution(uint16_t dutyCycleResolution)
void enableChannel(TimerUtils::Channel channel, Polarity polarity=Polarity::NORMAL)
void setFrequency(uint16_t pulseFrequency)
PWM(TIM_TypeDef *const pulseTimer, uint16_t pulseFrequency=50)
Sets up and enables the PWM timer.
GP16bitTimer & getTimer()
Returns the timer used to generate the pwm signal.
uint32_t getFrequency(TIM_TypeDef *timer)
Return the timer clock frequency.
This file includes all the types the logdecoder script will decode.