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:
parent
1c76469251
commit
cf219cd8a6
10 changed files with 28 additions and 0 deletions
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
||||
#include "build/atomic.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;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
||||
#include "drivers/io.h"
|
||||
#include "timer.h"
|
||||
|
||||
|
@ -111,3 +113,4 @@ ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index)
|
|||
#endif
|
||||
return IO_TAG_NONE;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
||||
#include "build/atomic.h"
|
||||
|
||||
#include "common/utils.h"
|
||||
|
@ -1121,3 +1123,4 @@ HAL_StatusTypeDef DMA_SetCurrDataCounter(TIM_HandleTypeDef *htim, uint32_t Chann
|
|||
/* Return function status */
|
||||
return HAL_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
@ -52,3 +54,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
|
|||
UNUSED(tim);
|
||||
return SystemCoreClock;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "stm32f30x.h"
|
||||
|
@ -44,3 +46,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
|
|||
UNUSED(tim);
|
||||
return SystemCoreClock;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "drivers/dma.h"
|
||||
|
@ -220,3 +222,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
|
|||
#error "No timer clock defined correctly for MCU"
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef USE_TIMER
|
||||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "drivers/dma.h"
|
||||
|
@ -205,3 +207,4 @@ uint32_t timerClock(TIM_TypeDef *tim)
|
|||
UNUSED(tim);
|
||||
return SystemCoreClock;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -358,7 +358,9 @@ void init(void)
|
|||
mcoInit(mcoConfig());
|
||||
#endif
|
||||
|
||||
#ifdef USE_TIMER
|
||||
timerInit(); // timer must be initialized before any channel is allocated
|
||||
#endif
|
||||
|
||||
#ifdef BUS_SWITCH_PIN
|
||||
busSwitchInit();
|
||||
|
@ -748,9 +750,11 @@ void init(void)
|
|||
|
||||
#endif // VTX_CONTROL
|
||||
|
||||
#ifdef USE_TIMER
|
||||
// start all timers
|
||||
// TODO - not implemented yet
|
||||
timerStart();
|
||||
#endif
|
||||
|
||||
ENABLE_STATE(SMALL_ANGLE);
|
||||
|
||||
|
|
|
@ -106,9 +106,11 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
|||
motorConfig->dev.useBurstDshot = ENABLE_DSHOT_DMAR;
|
||||
#endif
|
||||
|
||||
#ifdef USE_TIMER
|
||||
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS; motorIndex++) {
|
||||
motorConfig->dev.ioTags[motorIndex] = timerioTagGetByUsage(TIM_USE_MOTOR, motorIndex);
|
||||
}
|
||||
#endif
|
||||
|
||||
motorConfig->motorPoleCount = 14; // Most brushes motors that we use are 14 poles
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
|
||||
#define USE_PWM_OUTPUT
|
||||
#define USE_DMA
|
||||
#define USE_TIMER
|
||||
|
||||
#define USE_CLI
|
||||
#define USE_SERIAL_PASSTHROUGH
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue