Skyward boardcore
Loading...
Searching...
No Matches
TimerUtils.h File Reference
#include <utils/ClockUtils.h>
#include <cassert>
Include dependency graph for TimerUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Boardcore
 This file includes all the types the logdecoder script will decode.
 
namespace  Boardcore::TimerUtils
 Timer utilities.
 

Enumerations

enum class  Boardcore::TimerUtils::TriggerSource : uint16_t {
  Boardcore::TimerUtils::ITR0 = 0 , Boardcore::TimerUtils::ITR1 = TIM_SMCR_TS_0 , Boardcore::TimerUtils::ITR2 = TIM_SMCR_TS_1 , Boardcore::TimerUtils::ITR3 = TIM_SMCR_TS_1 | TIM_SMCR_TS_0 ,
  Boardcore::TimerUtils::TI1F_ED = TIM_SMCR_TS_2 , Boardcore::TimerUtils::TI1FP1 = TIM_SMCR_TS_2 | TIM_SMCR_TS_0 , Boardcore::TimerUtils::TI2FP2 = TIM_SMCR_TS_2 | TIM_SMCR_TS_1
}
 Trigger sources. More...
 
enum class  Boardcore::TimerUtils::MasterMode : uint32_t {
  Boardcore::TimerUtils::RESET = 0 , Boardcore::TimerUtils::ENABLE = TIM_CR2_MMS_0 , Boardcore::TimerUtils::UPDATE = TIM_CR2_MMS_1 , Boardcore::TimerUtils::COMPARE_PULSE = TIM_CR2_MMS_1 | TIM_CR2_MMS_0 ,
  Boardcore::TimerUtils::OC1REF_OUTPUT = TIM_CR2_MMS_2 , Boardcore::TimerUtils::OC2REF_OUTPUT = TIM_CR2_MMS_2 | TIM_CR2_MMS_0 , Boardcore::TimerUtils::OC3REF_OUTPUT = TIM_CR2_MMS_2 | TIM_CR2_MMS_1 , Boardcore::TimerUtils::OC4REF_OUTPUT = TIM_CR2_MMS
}
 
enum class  Boardcore::TimerUtils::SlaveMode : uint16_t {
  Boardcore::TimerUtils::DISABLED = 0 , Boardcore::TimerUtils::RESET_MODE = TIM_SMCR_SMS_2 , Boardcore::TimerUtils::GATED_MODE = TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0 , Boardcore::TimerUtils::TRIGGER_MODE = TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 ,
  Boardcore::TimerUtils::EXTERNAL_CLOCK_MODE_1 = TIM_SMCR_SMS_0 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_2
}
 
enum class  Boardcore::TimerUtils::OutputCompareMode : uint16_t {
  Boardcore::TimerUtils::FROZEN = 0 , Boardcore::TimerUtils::ACTIVE_ON_MATCH = 0x1 , Boardcore::TimerUtils::INACTIVE_ON_MATCH = 0x2 , Boardcore::TimerUtils::TOGGLE = 0x3 ,
  Boardcore::TimerUtils::FORCE_INACTIVE = 0x4 , Boardcore::TimerUtils::FORCE_ACTIVE = 0x5 , Boardcore::TimerUtils::PWM_MODE_1 = 0x6 , Boardcore::TimerUtils::PWM_MODE_2 = 0x7
}
 
enum class  Boardcore::TimerUtils::OutputComparePolarity : uint16_t { Boardcore::TimerUtils::ACTIVE_HIGH = 0 , Boardcore::TimerUtils::ACTIVE_LOW = 0x1 }
 
enum class  Boardcore::TimerUtils::Channel : uint8_t { Boardcore::TimerUtils::CHANNEL_1 = 0 , Boardcore::TimerUtils::CHANNEL_2 = 1 , Boardcore::TimerUtils::CHANNEL_3 = 2 , Boardcore::TimerUtils::CHANNEL_4 = 3 }
 

Functions

ClockUtils::APB Boardcore::TimerUtils::getTimerInputClock (const TIM_TypeDef *timer)
 Returns the timer input clock.
 
uint32_t Boardcore::TimerUtils::getPrescalerInputFrequency (const TIM_TypeDef *timer)
 Returns the timer clock frequency before the prescaler.
 
uint32_t Boardcore::TimerUtils::getFrequency (TIM_TypeDef *timer)
 Return the timer clock frequency.
 
float Boardcore::TimerUtils::toMicroSeconds (TIM_TypeDef *timer, uint32_t value)
 Returns the specified value converted in microseconds based on the timer clock frequency and prescaler.
 
float Boardcore::TimerUtils::toMicroSeconds (TIM_TypeDef *timer)
 Returns the timer counter converted in microseconds based on the timer clock frequency and prescaler.
 
uint64_t Boardcore::TimerUtils::toIntMicroSeconds (TIM_TypeDef *timer, uint32_t value)
 Returns the specified value converted in microseconds based on the timer clock frequency and prescaler.
 
uint64_t Boardcore::TimerUtils::toIntMicroSeconds (TIM_TypeDef *timer)
 Returns the timer counter converted in microseconds based on the timer clock frequency and prescaler.
 
float Boardcore::TimerUtils::toMilliSeconds (TIM_TypeDef *timer, uint32_t value)
 Returns the specified value converted in milliseconds based on the timer clock frequency and prescaler.
 
float Boardcore::TimerUtils::toMilliSeconds (TIM_TypeDef *timer)
 Returns the timer counter converted in milliseconds based on the timer clock frequency and prescaler.
 
float Boardcore::TimerUtils::toSeconds (TIM_TypeDef *timer)
 Returns the timer counter converted in seconds based on the timer clock frequency and prescaler.
 
float Boardcore::TimerUtils::getResolution (TIM_TypeDef *timer)
 Computes the timer resolution in microseconds.
 
float Boardcore::TimerUtils::getMaxDuration (TIM_TypeDef *timer)
 Computes the number of seconds for timer reset.
 
uint16_t Boardcore::TimerUtils::computePrescalerValue (TIM_TypeDef *timer, int targetFrequency)
 Compute the prescaler value for the specified target frequency.
 
MasterMode Boardcore::TimerUtils::masterModeFromChannel (const Channel channel)
 Returns the corresponding master for for the given channel.