79 ITR3 = TIM_SMCR_TS_1 | TIM_SMCR_TS_0,
89 TI1FP1 = TIM_SMCR_TS_2 | TIM_SMCR_TS_0,
94 TI2FP2 = TIM_SMCR_TS_2 | TIM_SMCR_TS_1
376 if (timer == TIM1 || timer == TIM8 || timer == TIM9 || timer == TIM10 ||
399 return (1.0f * value * 1e6 * (1 + timer->PSC)) /
411 return ((uint64_t)value * 1e6 * (uint64_t)(1 + timer->PSC)) /
422 return (1.0f * value * 1e3 * (1 + timer->PSC)) /
433 return (1.0f * timer->CNT * (1 + timer->PSC)) /
444 return (1.0f * timer->ARR * 1e6 * (1 + timer->PSC)) /
451 int32_t targetPrescaler =
453 return targetPrescaler >= 0 ? targetPrescaler : 0;
461 case Channel::CHANNEL_1:
462 return MasterMode::OC1REF_OUTPUT;
463 case Channel::CHANNEL_2:
464 return MasterMode::OC2REF_OUTPUT;
465 case Channel::CHANNEL_3:
466 return MasterMode::OC3REF_OUTPUT;
467 case Channel::CHANNEL_4:
468 return MasterMode::OC4REF_OUTPUT;
470 assert(
false &&
"Invalid channel!");
471 return MasterMode::RESET;
uint32_t getAPBTimersClock(APB bus)
Computes the output clock frequency for timers on the given APB.
float toMicroSeconds(TIM_TypeDef *timer, uint32_t value)
Returns the specified value converted in microseconds based on the timer clock frequency and prescale...
ClockUtils::APB getTimerInputClock(const TIM_TypeDef *timer)
Returns the timer input clock.
uint32_t getPrescalerInputFrequency(const TIM_TypeDef *timer)
Returns the timer clock frequency before the prescaler.
uint64_t toIntMicroSeconds(TIM_TypeDef *timer, uint32_t value)
Returns the specified value converted in microseconds based on the timer clock frequency and prescale...
float toMilliSeconds(TIM_TypeDef *timer, uint32_t value)
Returns the specified value converted in milliseconds based on the timer clock frequency and prescale...
TriggerSource
Trigger sources.
@ TI1FP1
Filtered timer input 1.
@ ITR1
Internal trigger 1.
@ TI1F_ED
TI1 edge detector.
@ TI2FP2
Filtered timer input 2.
@ ITR0
Internal trigger 0.
@ ITR3
Internal trigger 3.
@ ITR2
Internal trigger 2.
@ OC2REF_OUTPUT
OC2REF signal is used as trigger output (TRGO).
@ UPDATE
The UEV is selected as trigger output.
@ OC4REF_OUTPUT
OC4REF signal is used as trigger output (TRGO).
@ COMPARE_PULSE
The trigger output send a positive pulse when the OC1IF flag is to be set (even if it was already hig...
@ OC1REF_OUTPUT
OC1REF signal is used as trigger output (TRGO).
@ ENABLE
Only the timer enable is used as trigger output.
@ RESET
Only the updateGeneration() function is used as trigger output.
@ OC3REF_OUTPUT
OC3REF signal is used as trigger output (TRGO).
float getMaxDuration(TIM_TypeDef *timer)
Computes the number of seconds for timer reset.
uint32_t getFrequency(TIM_TypeDef *timer)
Return the timer clock frequency.
@ DISABLED
Slave mode disabled.
@ TRIGGER_MODE
Trigger mode.
@ EXTERNAL_CLOCK_MODE_1
External clock mode 1.
float getResolution(TIM_TypeDef *timer)
Computes the timer resolution in microseconds.
float toSeconds(TIM_TypeDef *timer)
Returns the timer counter converted in seconds based on the timer clock frequency and prescaler.
@ FROZEN
The comparison between the output compare register and the counter has no effect on the outputs.
@ TOGGLE
The output toggles when the output compare register and the counter match.
@ ACTIVE_ON_MATCH
Set channel to active level on match.
@ PWM_MODE_1
Output is active as long as the counter is smaller than the compare register (reverse when downcounti...
@ FORCE_ACTIVE
Output is forced high.
@ FORCE_INACTIVE
Output is forced low.
@ INACTIVE_ON_MATCH
Set channel to inactive level on match.
@ PWM_MODE_2
Output is active as long as the counter is greater than the compare register (reverse when downcounti...
uint16_t computePrescalerValue(TIM_TypeDef *timer, int targetFrequency)
Compute the prescaler value for the specified target frequency.
MasterMode masterModeFromChannel(const Channel channel)
Returns the corresponding master for for the given channel.
Driver for the VN100S IMU.