31 TIM_TypeDef*
const counterTimer,
34 : pulseTimer(pulseTimer), pulseChannel(pulseChannel),
35 pulseTriggerSource(pulseTriggerSource), counterTimer(counterTimer),
36 counterChannel(counterChannel), counterTriggerSource(counterTriggerSource)
39 this->pulseTimer.reset();
40 this->counterTimer.reset();
46 this->pulseTimer.enable();
47 this->counterTimer.enable();
58 this->pulseFrequency = pulseFrequency;
60 if (pulseFrequency == 0)
63 pulseTimer.
setFrequency(pulseFrequency * dutyCycleResolution);
70 if (dutyCycle >= 0 && dutyCycle <= 1)
72 this->dutyCycle = dutyCycle;
75 static_cast<uint16_t
>(
82 this->dutyCycleResolution = dutyCycleResolution;
102void CountedPWM::configureTimers()
109 pulseTimer.
setMasterMode(masterModeFromChannel(pulseChannel));
131 counterTimer.
setMasterMode(masterModeFromChannel(counterChannel));
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 generatePulses(uint16_t pulses)
Triggers the generation of a specific number of PWM periods.
void setFrequency(unsigned int pulseFrequency)
void setDutyCycle(float dutyCycle)
Sets the duty cycle for the specified channel.
CountedPWM(TIM_TypeDef *const pulseTimer, TimerUtils::Channel const pulseChannel, TimerUtils::TriggerSource const pulseTriggerSource, TIM_TypeDef *const counterTimer, TimerUtils::Channel const counterChannel, TimerUtils::TriggerSource const counterTriggerSource)
Constructor that initializes the timers.
void setDutyCycleResolution(unsigned int dutyCycleResolution)
Sets the granularity of the PulseTimer duty cycle. So it sets the Auto Reload Register of the PulseTi...
bool isGenerating()
Returns whether the timers are generating the PWM signal or not.
void enableCaptureCompareOutput(TimerUtils::Channel channel)
void setCaptureCompareRegister(TimerUtils::Channel channel, T value)
void setMasterMode(TimerUtils::MasterMode masterMode) override
void setOutputCompareMode(TimerUtils::Channel channel, TimerUtils::OutputCompareMode modeChannel)
void setCounter(T counterValue)
void setTriggerSource(TimerUtils::TriggerSource triggerSource)
void reset() override
Resets the timer configuration to the default state.
void setAutoReloadRegister(T autoReloadValue)
T readCaptureCompareRegister(TimerUtils::Channel channel)
void setSlaveMode(TimerUtils::SlaveMode slaveMode)
T readAutoReloadRegister()
TriggerSource
Trigger sources.
uint32_t getFrequency(TIM_TypeDef *timer)
Return the timer clock frequency.
@ EXTERNAL_CLOCK_MODE_1
External clock mode 1.
@ PWM_MODE_1
Output is active as long as the counter is smaller than the compare register (reverse when downcounti...
This file includes all the types the logdecoder script will decode.