1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Add and handle USE_TIMER

This commit is contained in:
jflyper 2019-05-05 19:42:30 +09:00
parent 1c76469251
commit cf219cd8a6
10 changed files with 28 additions and 0 deletions

View file

@ -25,6 +25,8 @@
#include "platform.h" #include "platform.h"
#ifdef USE_TIMER
#include "build/atomic.h" #include "build/atomic.h"
#include "common/utils.h" #include "common/utils.h"
@ -922,3 +924,4 @@ uint16_t timerGetPrescalerByDesiredHertz(TIM_TypeDef *tim, uint32_t hz)
} }
return (uint16_t)((timerClock(tim) + hz / 2 ) / hz) - 1; return (uint16_t)((timerClock(tim) + hz / 2 ) / hz) - 1;
} }
#endif

View file

@ -20,6 +20,8 @@
#include "platform.h" #include "platform.h"
#ifdef USE_TIMER
#include "drivers/io.h" #include "drivers/io.h"
#include "timer.h" #include "timer.h"
@ -111,3 +113,4 @@ ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index)
#endif #endif
return IO_TAG_NONE; return IO_TAG_NONE;
} }
#endif

View file

@ -25,6 +25,8 @@
#include "platform.h" #include "platform.h"
#ifdef USE_TIMER
#include "build/atomic.h" #include "build/atomic.h"
#include "common/utils.h" #include "common/utils.h"
@ -1121,3 +1123,4 @@ HAL_StatusTypeDef DMA_SetCurrDataCounter(TIM_HandleTypeDef *htim, uint32_t Chann
/* Return function status */ /* Return function status */
return HAL_OK; return HAL_OK;
} }
#endif

View file

@ -20,6 +20,8 @@
#include "platform.h" #include "platform.h"
#ifdef USE_TIMER
#include "common/utils.h" #include "common/utils.h"
#include "stm32f10x.h" #include "stm32f10x.h"
@ -52,3 +54,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
UNUSED(tim); UNUSED(tim);
return SystemCoreClock; return SystemCoreClock;
} }
#endif

View file

@ -20,6 +20,8 @@
#include "platform.h" #include "platform.h"
#ifdef USE_TIMER
#include "common/utils.h" #include "common/utils.h"
#include "stm32f30x.h" #include "stm32f30x.h"
@ -44,3 +46,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
UNUSED(tim); UNUSED(tim);
return SystemCoreClock; return SystemCoreClock;
} }
#endif

View file

@ -20,6 +20,8 @@
#include "platform.h" #include "platform.h"
#ifdef USE_TIMER
#include "common/utils.h" #include "common/utils.h"
#include "drivers/dma.h" #include "drivers/dma.h"
@ -220,3 +222,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
#error "No timer clock defined correctly for MCU" #error "No timer clock defined correctly for MCU"
#endif #endif
} }
#endif

View file

@ -20,6 +20,8 @@
#include "platform.h" #include "platform.h"
#ifdef USE_TIMER
#include "common/utils.h" #include "common/utils.h"
#include "drivers/dma.h" #include "drivers/dma.h"
@ -205,3 +207,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
UNUSED(tim); UNUSED(tim);
return SystemCoreClock; return SystemCoreClock;
} }
#endif

View file

@ -358,7 +358,9 @@ void init(void)
mcoInit(mcoConfig()); mcoInit(mcoConfig());
#endif #endif
#ifdef USE_TIMER
timerInit(); // timer must be initialized before any channel is allocated timerInit(); // timer must be initialized before any channel is allocated
#endif
#ifdef BUS_SWITCH_PIN #ifdef BUS_SWITCH_PIN
busSwitchInit(); busSwitchInit();
@ -748,9 +750,11 @@ void init(void)
#endif // VTX_CONTROL #endif // VTX_CONTROL
#ifdef USE_TIMER
// start all timers // start all timers
// TODO - not implemented yet // TODO - not implemented yet
timerStart(); timerStart();
#endif
ENABLE_STATE(SMALL_ANGLE); ENABLE_STATE(SMALL_ANGLE);

View file

@ -106,9 +106,11 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig)
motorConfig->dev.useBurstDshot = ENABLE_DSHOT_DMAR; motorConfig->dev.useBurstDshot = ENABLE_DSHOT_DMAR;
#endif #endif
#ifdef USE_TIMER
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS; motorIndex++) { for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS; motorIndex++) {
motorConfig->dev.ioTags[motorIndex] = timerioTagGetByUsage(TIM_USE_MOTOR, motorIndex); motorConfig->dev.ioTags[motorIndex] = timerioTagGetByUsage(TIM_USE_MOTOR, motorIndex);
} }
#endif
motorConfig->motorPoleCount = 14; // Most brushes motors that we use are 14 poles motorConfig->motorPoleCount = 14; // Most brushes motors that we use are 14 poles
} }

View file

@ -142,6 +142,7 @@
#define USE_PWM_OUTPUT #define USE_PWM_OUTPUT
#define USE_DMA #define USE_DMA
#define USE_TIMER
#define USE_CLI #define USE_CLI
#define USE_SERIAL_PASSTHROUGH #define USE_SERIAL_PASSTHROUGH