99 #define CC_CHANNELS_PER_TIMER 4 // TIM_Channel_1..4 130 for (timerIndex = 0; timerIndex <
MAX_TIMERS; timerIndex++ ) {
131 if (timers[timerIndex] == tim)
141 if (channels[channelIndex].channel == channel)
158 timerConfigs[timerIndex][channelIndex].
callback = callback;
160 timerConfigs[timerIndex][channelIndex].
reference = reference;
203 TIM_TimeBaseStructure.
TIM_Period = period - 1;
228 return &(timerConfigs[timerIndex][channelIndex]);
233 unsigned int channelIndex;
uint32_t TIM_GetCapture3(TIM_TypeDef *TIMx)
Gets the TIMx Input Capture 3 value.
void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct)
Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.
uint32_t TIM_GetCapture1(TIM_TypeDef *TIMx)
Gets the TIMx Input Capture 1 value.
#define CC_CHANNELS_PER_TIMER
void TIM_TimeBaseInit(TIM_TypeDef *TIMx, TIM_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct)
Initializes the TIMx Time Base Unit peripheral according to the specified parameters in the TIM_TimeB...
timerConfig_t timerConfigs[MAX_TIMERS][CC_CHANNELS_PER_TIMER]
void TIM2_IRQHandler(void)
void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct)
Fills each TIM_TimeBaseInitStruct member with its default value.
void configureTimerChannelCallback(TIM_TypeDef *tim, uint8_t channel, uint8_t reference, timerCCCallbackPtr *callback)
ITStatus TIM_GetITStatus(TIM_TypeDef *TIMx, uint16_t TIM_IT)
Checks whether the TIM interrupt has occurred or not.
void assert_param(int val)
void timerCCCallbackPtr(uint8_t port, uint16_t capture)
uint8_t NVIC_IRQChannelSubPriority
NVIC Init Structure definition.
uint32_t TIM_GetCapture2(TIM_TypeDef *TIMx)
Gets the TIMx Input Capture 2 value.
static timerConfig_t * findTimerConfig(unsigned int timerIndex, unsigned int channelIndex)
void TIM4_IRQHandler(void)
const timerHardware_t timerHardware[]
void TIM_Cmd(TIM_TypeDef *TIMx, FunctionalState NewState)
Enables or disables the specified TIM peripheral.
void configureTimerCaptureCompareInterrupt(const timerHardware_t *timerHardwarePtr, uint8_t reference, timerCCCallbackPtr *callback)
timerCCCallbackPtr * callback
void TIM3_IRQHandler(void)
#define IS_TIM_CHANNEL(CHANNEL)
uint32_t TIM_GetCapture4(TIM_TypeDef *TIMx)
Gets the TIMx Input Capture 4 value.
static const channelConfig_t channels[CC_CHANNELS_PER_TIMER]
void timerConfigure(const timerHardware_t *timerHardwarePtr, uint16_t period, uint8_t mhz)
uint16_t TIM_ClockDivision
TIM Time Base Init structure definition.
FunctionalState NVIC_IRQChannelCmd
void TIM_ITConfig(TIM_TypeDef *TIMx, uint16_t TIM_IT, FunctionalState NewState)
Enables or disables the specified TIM interrupts.
struct channelConfig_s channelConfig_t
uint8_t NVIC_IRQChannelPreemptionPriority
void timerNVICConfigure(uint8_t irq)
uint16_t(* TIM_GetCaptureFn)(TIM_TypeDef *TIMx)
static int lookupChannelIndex(const int channel)
static void timCCxHandler(TIM_TypeDef *const tim, unsigned int timerIndex)
void TIM1_CC_IRQHandler(void)
static const TIM_TypeDef *const timers[MAX_TIMERS]
static int lookupTimerIndex(const TIM_TypeDef *tim)
void configureTimerInputCaptureCompareChannel(TIM_TypeDef *tim, const uint8_t channel)
void configTimeBase(TIM_TypeDef *tim, uint16_t period, uint8_t mhz)
#define TIM_CounterMode_Up
struct timerConfig_s timerConfig_t
void TIM_ClearITPendingBit(TIM_TypeDef *TIMx, uint16_t TIM_IT)
Clears the TIMx's interrupt pending bits.