mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 17:55:28 +03:00
replace timerClockDivisor with timerClock
for more flexible timer clocks
This commit is contained in:
parent
c8e78aa63f
commit
586b9916b0
7 changed files with 9 additions and 21 deletions
|
@ -169,7 +169,7 @@ static bool isTimerPeriodTooLarge(uint32_t timerPeriod)
|
||||||
|
|
||||||
static void serialTimerConfigureTimebase(TCH_t * tch, uint32_t baud)
|
static void serialTimerConfigureTimebase(TCH_t * tch, uint32_t baud)
|
||||||
{
|
{
|
||||||
uint32_t baseClock = SystemCoreClock / timerClockDivisor(tch->timHw->tim);
|
uint32_t baseClock = timerClock(tch->timHw->tim);
|
||||||
uint32_t clock = baseClock;
|
uint32_t clock = baseClock;
|
||||||
uint32_t timerPeriod;
|
uint32_t timerPeriod;
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ uint32_t timerGetBaseClock(TCH_t * tch)
|
||||||
|
|
||||||
uint32_t timerGetBaseClockHW(const timerHardware_t * timHw)
|
uint32_t timerGetBaseClockHW(const timerHardware_t * timHw)
|
||||||
{
|
{
|
||||||
return SystemCoreClock / timerClockDivisor(timHw->tim);
|
return timerClock(timHw->tim);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool timerPWMConfigChannelDMA(TCH_t * tch, void * dmaBuffer, uint8_t dmaBufferElementSize, uint32_t dmaBufferElementCount)
|
bool timerPWMConfigChannelDMA(TCH_t * tch, void * dmaBuffer, uint8_t dmaBufferElementSize, uint32_t dmaBufferElementCount)
|
||||||
|
|
|
@ -157,7 +157,7 @@ typedef enum {
|
||||||
TYPE_TIMER
|
TYPE_TIMER
|
||||||
} channelType_t;
|
} channelType_t;
|
||||||
|
|
||||||
uint8_t timerClockDivisor(TIM_TypeDef *tim);
|
uint32_t timerClock(TIM_TypeDef *tim);
|
||||||
uint32_t timerGetBaseClockHW(const timerHardware_t * timHw);
|
uint32_t timerGetBaseClockHW(const timerHardware_t * timHw);
|
||||||
|
|
||||||
const timerHardware_t * timerGetByUsageFlag(timerUsageFlag_e flag);
|
const timerHardware_t * timerGetByUsageFlag(timerUsageFlag_e flag);
|
||||||
|
|
|
@ -48,10 +48,10 @@ const timerDef_t timerDefinitions[HARDWARE_TIMER_DEFINITION_COUNT] = {
|
||||||
[16] = { .tim = TIM17, .rcc = RCC_APB2(TIM17), .irq = TIM1_TRG_COM_TIM17_IRQn },
|
[16] = { .tim = TIM17, .rcc = RCC_APB2(TIM17), .irq = TIM1_TRG_COM_TIM17_IRQn },
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t timerClockDivisor(TIM_TypeDef *tim)
|
uint32_t timerClock(TIM_TypeDef *tim)
|
||||||
{
|
{
|
||||||
UNUSED(tim);
|
UNUSED(tim);
|
||||||
return 1;
|
return SystemCoreClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
_TIM_IRQ_HANDLER(TIM1_CC_IRQHandler, 1);
|
_TIM_IRQ_HANDLER(TIM1_CC_IRQHandler, 1);
|
||||||
|
|
|
@ -95,16 +95,16 @@ const timerDef_t timerDefinitions[HARDWARE_TIMER_DEFINITION_COUNT] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t timerClockDivisor(TIM_TypeDef *tim)
|
uint32_t timerClock(TIM_TypeDef *tim)
|
||||||
{
|
{
|
||||||
#if defined (STM32F411xE)
|
#if defined (STM32F411xE)
|
||||||
UNUSED(tim);
|
UNUSED(tim);
|
||||||
return 1;
|
return SystemCoreClock;
|
||||||
#elif defined (STM32F40_41xxx) || defined (STM32F427_437xx) || defined (STM32F446xx)
|
#elif defined (STM32F40_41xxx) || defined (STM32F427_437xx) || defined (STM32F446xx)
|
||||||
if (tim == TIM1 || tim == TIM8 || tim == TIM9 || tim == TIM10 || tim == TIM11) {
|
if (tim == TIM1 || tim == TIM8 || tim == TIM9 || tim == TIM10 || tim == TIM11) {
|
||||||
return 1;
|
return SystemCoreClock;
|
||||||
} else {
|
} else {
|
||||||
return 2;
|
return SystemCoreClock / 2;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#error "No timer clock defined correctly for the MCU"
|
#error "No timer clock defined correctly for the MCU"
|
||||||
|
|
|
@ -48,12 +48,6 @@ const timerDef_t timerDefinitions[HARDWARE_TIMER_DEFINITION_COUNT] = {
|
||||||
[13] = { .tim = TIM14, .rcc = RCC_APB1(TIM14), .irq = TIM8_TRG_COM_TIM14_IRQn},
|
[13] = { .tim = TIM14, .rcc = RCC_APB1(TIM14), .irq = TIM8_TRG_COM_TIM14_IRQn},
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t timerClockDivisor(TIM_TypeDef *tim)
|
|
||||||
{
|
|
||||||
UNUSED(tim);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t timerClock(TIM_TypeDef *tim)
|
uint32_t timerClock(TIM_TypeDef *tim)
|
||||||
{
|
{
|
||||||
UNUSED(tim);
|
UNUSED(tim);
|
||||||
|
|
|
@ -48,12 +48,6 @@ const timerDef_t timerDefinitions[HARDWARE_TIMER_DEFINITION_COUNT] = {
|
||||||
[13] = { .tim = TIM17, .rcc = RCC_APB2(TIM17), .irq = TIM17_IRQn},
|
[13] = { .tim = TIM17, .rcc = RCC_APB2(TIM17), .irq = TIM17_IRQn},
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t timerClockDivisor(TIM_TypeDef *tim)
|
|
||||||
{
|
|
||||||
UNUSED(tim);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t timerClock(TIM_TypeDef *tim)
|
uint32_t timerClock(TIM_TypeDef *tim)
|
||||||
{
|
{
|
||||||
int timpre;
|
int timpre;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue