mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Initial preparation for cleaning up multiple files per MCU (#2500)
* Initial preparation for cleaning up multiple files per MCU * Combined DSHOT for F3 and F4 (F7 todo) * Build fixes (mixed some adjustments needed in transponder_ir.c) * Fix F7 warnings/bugs * Updated timer periods for transponder. Fixed FURY including old pwm_output files. * Added method to calculate prescaler and period on the fly for varying clock speeds. This can be used for overclocking :) * Consolidated led_strip * Moved led strip to use system clock for timing (allowing overclocking) * Fixed incorrect channel, and removed comparison warning. * More cleanup * Fix KIWIF4 target * Cleaned up target.mk files
This commit is contained in:
parent
67ac6dfefa
commit
792941606f
30 changed files with 204 additions and 653 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
|
@ -842,3 +843,17 @@ uint16_t timerDmaSource(uint8_t channel)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t timerGetPrescalerByDesiredMhz(TIM_TypeDef *tim, uint16_t mhz)
|
||||
{
|
||||
// protection here for desired MHZ > SystemCoreClock???
|
||||
if ((uint32_t)(mhz * 1000000) > (SystemCoreClock / timerClockDivisor(tim))) {
|
||||
return 0;
|
||||
}
|
||||
return (uint16_t)(round((SystemCoreClock / timerClockDivisor(tim) / (mhz * 1000000)) - 1));
|
||||
}
|
||||
|
||||
uint16_t timerGetPeriodByPrescaler(TIM_TypeDef *tim, uint16_t prescaler, uint32_t hertz)
|
||||
{
|
||||
return ((uint16_t)((SystemCoreClock / timerClockDivisor(tim) / (prescaler + 1)) / hertz));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue