1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

DSHOT - Use cycle counting instead of recording timestamp in dshot motor_DMA_IRQHandler.

It turns out that two calls to micros() and the calculation of
directionChangeDurationUs took 581 cycles, vs 396 cycles without the
calls to micros() and deferred calculation of the duration which is only
needed in the CLI.

This brings the time down from around 7 microseconds to 5.5 microseconds
on an F3 at 72Mhz.

This makes the difference between 100% invalid telemetry and 4% invalid
telemetry on the first motor on the F3.

Squashed commits:
* Remove the forward declaration for `pwmDshotSetDirectionInput` and make
it static.
* Remove unneeded forward declaration of `motor_DMA_IRQHandler`.
* Remove duplication in DMA IRQ Handler.
  Doesn't affect resulting code but improves readability.
* Use an inline function to read DWT->CYCCNT.
* Remove unneeded forward declarations from cli.c now that the correct
header is included.
* Update DWT unlock method.
This commit is contained in:
Dominic Clifton 2019-08-28 11:21:06 +02:00
parent 6f4c2bb48c
commit d016aa2fc4
8 changed files with 76 additions and 33 deletions

View file

@ -64,10 +64,13 @@ void systemReset(void);
void systemResetToBootloader(bootloaderRequestType_e requestType);
bool isMPUSoftReset(void);
void cycleCounterInit(void);
uint32_t clockCyclesToMicros(uint32_t clockCycles);
uint32_t getCycleCounter(void);
#if defined(STM32H7)
void systemCheckResetReason(void);
#endif
void initialiseMemorySections(void);
void enableGPIOPowerUsageAndNoiseReductions(void);