101 static_assert(std::is_same<T, uint16_t>::value ||
102 std::is_same<T, uint32_t>::value,
103 "Type must be either uint16_t or uint32_t.");
248 timer->ARR =
static_cast<uint32_t
>(0xFFFFFFFFF);
261 timer->CR1 |= TIM_CR1_CEN;
265 if (timer == TIM1 || timer == TIM8)
266 timer->BDTR |= TIM_BDTR_MOE;
272 timer->CR1 &= ~TIM_CR1_CEN;
276 if (timer == TIM1 || timer == TIM8)
277 timer->BDTR |= TIM_BDTR_MOE;
289 timer->CNT = counterValue;
301 timer->ARR = autoReloadValue;
309 timer->CR2 &= ~TIM_CR2_MMS;
312 timer->CR2 |=
static_cast<uint16_t
>(masterMode);
320 timer->SMCR &= ~TIM_SMCR_SMS;
323 timer->SMCR |=
static_cast<uint16_t
>(slaveMode);
331 timer->SMCR &= ~TIM_SMCR_TS;
334 timer->SMCR |=
static_cast<uint16_t
>(triggerSource);
340 timer->DIER |= TIM_DIER_TIE;
346 timer->DIER &= ~TIM_DIER_TIE;
353 timer->DIER |= TIM_DIER_CC1IE << static_cast<int>(channel);
360 timer->DIER &= ~(TIM_DIER_CC1IE << static_cast<int>(channel));
367 timer->DIER |= TIM_DIER_CC1DE << static_cast<int>(channel);
374 timer->DIER &= ~(TIM_DIER_CC1DE << static_cast<int>(channel));
380 timer->EGR |= TIM_EGR_TG;
387 timer->EGR |= TIM_EGR_CC1G << static_cast<int>(channel);
397 timer->CCMR1 |= TIM_CCMR1_OC1PE;
400 timer->CCMR1 |= TIM_CCMR1_OC2PE;
403 timer->CCMR2 |= TIM_CCMR2_OC3PE;
406 timer->CCMR2 |= TIM_CCMR2_OC4PE;
418 timer->CCMR1 &= ~TIM_CCMR1_OC1PE;
421 timer->CCMR1 &= ~TIM_CCMR1_OC2PE;
424 timer->CCMR2 &= ~TIM_CCMR2_OC3PE;
427 timer->CCMR2 &= ~TIM_CCMR2_OC4PE;
440 timer->CCMR1 &= ~TIM_CCMR1_OC1M;
443 timer->CCMR1 |=
static_cast<uint16_t
>(mode) << 4;
447 timer->CCMR1 &= ~TIM_CCMR1_OC2M;
450 timer->CCMR1 |=
static_cast<uint16_t
>(mode) << 12;
454 timer->CCMR2 &= ~TIM_CCMR2_OC3M;
457 timer->CCMR2 |=
static_cast<uint16_t
>(mode) << 4;
461 timer->CCMR2 &= ~TIM_CCMR2_OC4M;
464 timer->CCMR2 |=
static_cast<uint16_t
>(mode) << 12;
473 timer->CCER |= TIM_CCER_CC1E << (static_cast<int>(channel) * 4);
480 timer->CCER |= TIM_CCER_CC1NE << (static_cast<int>(channel) * 4);
487 timer->CCER &= ~(TIM_CCER_CC1E << (static_cast<int>(channel) * 4));
494 timer->CCER &= ~(TIM_CCER_CC1NE << (static_cast<int>(channel) * 4));
501 return timer->CCER & (TIM_CCER_CC1E << (static_cast<int>(channel) * 4));
508 return timer->CCER & (TIM_CCER_CC1NE << (static_cast<int>(channel) * 4));
515 timer->CCER |=
static_cast<uint16_t
>(polarity)
516 << (1 +
static_cast<int>(channel) * 4);
523 timer->CCER |=
static_cast<uint16_t
>(polarity)
524 << (3 +
static_cast<int>(channel) * 4);
570 timer->SR &= ~TIM_SR_TIF;
577 timer->SR &= ~(TIM_SR_CC1IF << static_cast<int>(channel));
Driver for STM32 basic timers.
Driver for STM32 general purpose timers.
void enableCaptureCompareOutput(TimerUtils::Channel channel)
GeneralPurposeTimer(TIM_TypeDef *timer)
Create a GeneralPurposeTimer object. Note that this does not resets the timer configuration but autom...
void clearTriggerInterruptFlag()
~GeneralPurposeTimer()
Disables the peripheral clock.
void setCaptureCompareRegister(TimerUtils::Channel channel, T value)
void generateCaptureCompareEvent(TimerUtils::Channel channel)
void enableCaptureCompareComplementaryOutput(TimerUtils::Channel channel)
void enableCaptureComparePreload(TimerUtils::Channel channel)
The capture/compare register is buffered.
void enableCaptureCompareDMARequest(TimerUtils::Channel channel)
void setMasterMode(TimerUtils::MasterMode masterMode) override
void setOutputCompareMode(TimerUtils::Channel channel, TimerUtils::OutputCompareMode modeChannel)
void enableTriggerInterrupt()
void setCaptureComparePolarity(TimerUtils::Channel channel, TimerUtils::OutputComparePolarity polarity)
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 disableCaptureCompareDMARequest(TimerUtils::Channel channel)
void disableTriggerInterrupt()
void disableCaptureCompareOutput(TimerUtils::Channel channel)
void disableCaptureComparePreload(TimerUtils::Channel channel)
The capture/compare register is not buffered.
void setSlaveMode(TimerUtils::SlaveMode slaveMode)
void disableCaptureCompareComplementaryOutput(TimerUtils::Channel channel)
bool isCaptureCompareComplementaryOutputEnabled(TimerUtils::Channel channel)
bool isCaptureCompareOutputEnabled(TimerUtils::Channel channel)
void enableCaptureCompareInterrupt(TimerUtils::Channel channel)
void disableCaptureCompareInterrupt(TimerUtils::Channel channel)
void setCaptureCompareComplementaryPolarity(TimerUtils::Channel channel, TimerUtils::OutputComparePolarity polarity)
void clearCaptureCompareInterruptFlag(TimerUtils::Channel channel)
T readAutoReloadRegister()
bool disablePeripheralClock(void *peripheral)
Disables a peripheral clock source from the APB1 and APB2 peripheral buses.
TriggerSource
Trigger sources.
This file includes all the types the logdecoder script will decode.
GeneralPurposeTimer< uint32_t > GP32bitTimer
General purpose 32bit timer.